package com.y.server.controller;


import com.y.pojo.dto.UserDto;

import com.y.server.service.impl.UserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


    @RestController
    @RequestMapping("/api/users")
    public class UserController {
        @Autowired
        UserServiceImpl userService;

        // 注册接口
        @PostMapping("/register")
        public String register(@RequestBody UserDto user) {
            userService.register(user);
            return "注册成功";
        }

        // 登录接口
        @PostMapping("/login")
        public String login(@RequestParam UserDto username, @RequestParam String password) {
            userService.login(username);
            return "登陆成功";

        }
    }

